package com.haojin.java;

public class Method {
public static void main(String[] args) {
	Student1[] arr = new Student1[20];
	System.out.println("三年級的学生");
	for(int i = 0;i<arr.length;i++){
		arr[i] = new Student1();
		arr[i].number = i+1;
		arr[i].state= (int)(Math.random()*6+1);
		arr[i].score = (int)(Math.random()*101);
		if (arr[i].state == 3){
			arr[i].information();
		} 
	}
	System.out.println();
	System.out.println("按照成績排序：");
	for(int i = 0;i<arr.length-1;i++){
		for(int j =0;j<arr.length-1-i;j++){
			if( arr[j].score< arr[j+1].score){
			   Student1 tmp = arr[j];
			   arr[j] = arr[j+1];
			   arr[j+1]=tmp;
			}
		}
	}
	for(int i = 0;i<arr.length;i++){
		arr[i].information();
	}
}
}


class Student1{
	int number;
	int state ;
    int score ;
	public void information(){
		System.out.println("state："+state+"  number："+number+"  score："+score);
	}
}

